package com.ruoyi.web.controller.system;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.HatchetAcqMerchant;
import com.ruoyi.system.service.IHatchetAcqMerchantService;

/**
 * 通道商户 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-03-23
 */
@Controller
@RequestMapping("/system/hatchetAcqMerchant")
public class HatchetAcqMerchantController extends BaseController
{
    private String prefix = "system/hatchetAcqMerchant";
	
	@Autowired
	private IHatchetAcqMerchantService hatchetAcqMerchantService;
	
	@RequiresPermissions("system:hatchetAcqMerchant:view")
	@GetMapping()
	public String hatchetAcqMerchant()
	{
	    return prefix + "/hatchetAcqMerchant";
	}
	
	/**
	 * 查询通道商户列表
	 */
	@RequiresPermissions("system:hatchetAcqMerchant:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(HatchetAcqMerchant hatchetAcqMerchant)
	{
		startPage();
        List<HatchetAcqMerchant> list = hatchetAcqMerchantService.selectHatchetAcqMerchantList(hatchetAcqMerchant);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出通道商户列表
	 */
	@RequiresPermissions("system:hatchetAcqMerchant:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HatchetAcqMerchant hatchetAcqMerchant)
    {
    	List<HatchetAcqMerchant> list = hatchetAcqMerchantService.selectHatchetAcqMerchantList(hatchetAcqMerchant);
        ExcelUtil<HatchetAcqMerchant> util = new ExcelUtil<HatchetAcqMerchant>(HatchetAcqMerchant.class);
        return util.exportExcel(list, "hatchetAcqMerchant");
    }
	
	/**
	 * 新增通道商户
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存通道商户
	 */
	@RequiresPermissions("system:hatchetAcqMerchant:add")
	@Log(title = "通道商户", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(HatchetAcqMerchant hatchetAcqMerchant)
	{		
		return toAjax(hatchetAcqMerchantService.insertHatchetAcqMerchant(hatchetAcqMerchant));
	}

	/**
	 * 修改通道商户
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		HatchetAcqMerchant hatchetAcqMerchant = hatchetAcqMerchantService.selectHatchetAcqMerchantById(id);
		mmap.put("hatchetAcqMerchant", hatchetAcqMerchant);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存通道商户
	 */
	@RequiresPermissions("system:hatchetAcqMerchant:edit")
	@Log(title = "通道商户", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(HatchetAcqMerchant hatchetAcqMerchant)
	{		
		return toAjax(hatchetAcqMerchantService.updateHatchetAcqMerchant(hatchetAcqMerchant));
	}
	
	/**
	 * 删除通道商户
	 */
	@RequiresPermissions("system:hatchetAcqMerchant:remove")
	@Log(title = "通道商户", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(hatchetAcqMerchantService.deleteHatchetAcqMerchantByIds(ids));
	}
	
	
	/**
	 * 验证通道商户编号是否唯一
	 */
	  @PostMapping("/checkAcqMerchantNoUnique")
    @ResponseBody
    public String checkAcqMerchantNoUnique(HatchetAcqMerchant hatchetAcqMerchant)
	{		
		  return hatchetAcqMerchantService.checkAcqMerchantNoUnique(hatchetAcqMerchant); 
	
	}
}
